package com.xuecheng.api.media;

import com.xuecheng.framework.domain.media.response.CheckChunkResult;
import com.xuecheng.framework.model.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.multipart.MultipartFile;

/**
 * 视频文件上传接口
 */
@Api(value = "视频管理接口", tags = {"提供视频文件接口,提供视频文件上传下载,查询接口"})
public interface MediaUploadControllerApi {
    /**
     * 上传文件第1步->注册文件,检查文件是否存在
     *
     * @param path     文件路径
     * @param fileMd5  文件md5
     * @param fileName 文件名称
     * @param fileSize 文件大小
     * @param mimetype 文件类型
     * @param fileExt  文件扩展名
     * @return 状态
     */
    @ApiOperation("上传文件第1步->注册文件")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "文件md5", name = "fileMd5", required = true),
            @ApiImplicitParam(value = "文件名称", name = "fileName", required = true),
            @ApiImplicitParam(value = "文件大小", name = "fileSize", required = true),
            @ApiImplicitParam(value = "文件类型", name = "mimetype", required = true),
            @ApiImplicitParam(value = "文件扩展名", name = "fileExt", required = true),
            @ApiImplicitParam(value = "文件路径", name = "path", required = true)
    })
    ResponseResult register(String path, String fileMd5, String fileName, Long fileSize, String mimetype, String fileExt);


    /**
     * 上传文件第2步->检查分块是否存在
     *
     * @param path      文件路径
     * @param fileMd5   文件md5
     * @param chunk     分块下标
     * @param chunkSize 分块大小
     * @return 结果
     */
    @ApiOperation("上传文件第2步->检查分块是否存在")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "文件md5", name = "fileMd5", required = true),
            @ApiImplicitParam(value = "分块下标", name = "chunk", required = true),
            @ApiImplicitParam(value = "分块大小", name = "chunkSize", required = true),
            @ApiImplicitParam(value = "文件路径路径", name = "path", required = true),
    })
    CheckChunkResult checkChunk(String path, String fileMd5, Integer chunk, Long chunkSize);

    /**
     * 上传文件第3步->接收分块文件
     *
     * @param path    文件路径
     * @param file    分块文件
     * @param fileMd5 文件md5
     * @param chunk   分块下标
     * @return 结果
     */
    @ApiOperation("上传文件第3步->接收分块文件")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "文件", name = "file", required = true),
            @ApiImplicitParam(value = "文件md5", name = "fileMd5", required = true),
            @ApiImplicitParam(value = "分块下标", name = "chunk", required = true),
            @ApiImplicitParam(value = "文件路径路径", name = "path", required = true),
    })
    ResponseResult uploadChunk(String path, MultipartFile file, String fileMd5, Integer chunk);

    /**
     * 上传文件第4步->合并分块
     *
     * @param path     文件路径
     * @param fileMd5  文件md5
     * @param fileName 文件名称
     * @param fileSize 文件大小
     * @param mimetype 文件类型
     * @param fileExt  文件后缀
     * @return 结果
     */
    @ApiOperation("上传文件第4步->合并分块")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "文件md5", name = "fileMd5", required = true),
            @ApiImplicitParam(value = "文件名称", name = "fileName", required = true),
            @ApiImplicitParam(value = "文件大小", name = "fileSize", required = true),
            @ApiImplicitParam(value = "文件类型", name = "mimetype", required = true),
            @ApiImplicitParam(value = "文件后缀", name = "fileExt", required = true),
            @ApiImplicitParam(value = "文件路径路径", name = "path", required = true),
    })
    ResponseResult mergeChunks(String path, String fileMd5, String fileName, Long fileSize, String mimetype, String fileExt);

}
